package com.jianwei.service.segment;

import com.jianwei.configuration.Module;
import com.jianwei.service.IdService;
import com.jianwei.service.generator.IdGeneratorFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author wjwei
 */
@Module("segment.enable")
@Service
public class SegmentIdService implements IdService {

    @Autowired
    private IdGeneratorFactory idGeneratorFactory;

    @Override
    public long getNextId() {
        return 0;
    }

    @Override
    public long getNextId(String businessType) {
        return idGeneratorFactory.getIdGenerator(businessType).nextId();
    }

    @Override
    public Set<Long> batchGetNextId(int batchSize) {
        return null;
    }

    @Override
    public Set<Long> batchGetNextId(String businessType, int batcSize) {
        return idGeneratorFactory.getIdGenerator(businessType).nextIds(batcSize);
    }
}
